<template>
  <div class="app-container">
    <el-table v-loading="loading" :data="messageList">
      <el-table-column prop="index" label="序号" width="55" align="center"></el-table-column>
      <el-table-column label="创建时间" align="center" prop="createTime" />
      <el-table-column label="接收人" align="center" prop="messageReciver">
        <template slot-scope="scope">
          {{ scope.row.messageReciver === 'ALL' ? '全体用户' : scope.row.messageReciver }}
        </template>
      </el-table-column>
      <el-table-column label="消息" align="center" prop="message" width="600" />
      <el-table-column label="状态" align="center" prop="status">
        <template slot-scope="scope">
          {{ scope.row.status === "0" ? '未读' : scope.row.status === "1" ? '已读' : '公告' }}
        </template>
      </el-table-column>
      <el-table-column label="发送人" align="center" prop="messageSender">
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />

  </div>
</template>

<script>
import { messageList } from '@/api/login'

export default {
  name: "Message",
  data() {
    return {
      // 遮罩层
      loading: true,

      // 总条数
      // 公告通知表格数据
      messageList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        messageReciver: this.$route.query.messageReciver?this.$route.query.messageReciver:'ALL',
      },
      total:0
    };
  },
  created() {
    this.getList();
  },
  methods: {

    getList() {
      this.loading = true;
      messageList(this.queryParams.messageReciver).then(response => {
        this.messageList = response.rows
        this.messageList.forEach((item, index) => {
          item.index = (this.queryParams.pageNum - 1) * this.queryParams.pageSize + index + 1;
        });
        this.total = response.total;
        this.loading = false;
      });
    },

  }
};
</script>
